import React, { Component } from "react";
import {
  getBanner,
  getRecommendlist,
  getNewsong,
  getMv,
  getSongUrl,
} from "../../api/discovery.js";
export default class Discovery extends Component {
  /* 构造器开始*/
  constructor() {
    super();
  }
  /* 构造器结束*/
  /* state开始*/
  state = {
    // 轮播图
    banners: [],
    // 推荐歌单
    recommendList: [],
    // 新歌
    newsong: [],
    // mv
    mv: [],
    // 歌曲Url
    songUrl: "",
  };
  /* state结束*/
  /* 生命周期开始*/
  componentDidMount() {
    this.loadBanner();
    this.loadRecommend();
    this.loadNewSong();
    this.loadMV();
  }
  async loadBanner() {
    let res = await getBanner();
    const { banners } = res.data;
    this.setState({
      banners,
    });
  }
  async loadRecommend() {
    let res = await getRecommendlist();
    const { recommendList } = res.data;
    this.setState({
      recommendList,
    });
  }
  async loadNewSong() {
    let res = await getNewsong();
    const { newsong } = res.data;
    this.setState({
      newsong,
    });
  }
  async loadMV() {
    let res = await getMv();
    const { mv } = res.data;
    this.setState({
      mv,
    });
  }
  /* 生命周期结束*/
  render() {
    const { banners, recommendList, newsong, mv, songUrl } = this.state;
    return <div>发现音乐</div>;
  }
}
